package com.itany.corejava.code07_面向对象.多态;

import java.util.Scanner;

/**
 * @author: 石小俊
 * @date: 2023年03月08日 15:47
 * @version: 1.0
 */
public class Pet {
    private String name;
    private String gender;

    public void show() {
        System.out.println("我是一只宠物,我的名字叫做" + name + ",我的性别:" + gender);
    }

    public Pet() {
    }

    public Pet(String name, String gender) {
        this.name = name;
        this.gender = gender;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }
}

class Cat extends Pet {
    private String type;

    public Cat(String name, String gender, String type) {
        super(name, gender);
        this.type = type;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    @Override
    public void show() {
        System.out.println("我是一只宠物猫,我的名字叫做:" + getName() + ",性别:" + getGender() + ",品种:" + type);
    }
}

class Dog extends Pet {
    private int age;

    public Dog(String name, String gender, int age) {
        super(name, gender);
        this.age = age;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public void show() {
        System.out.println("我是一只宠物狗,我的名字叫做:" + getName() + ",性别:" + getGender() + ",年龄:" + age);
    }
}

class Pig extends Pet {
    private String hobby;

    public Pig(String name, String gender, String hobby) {
        super(name, gender);
        this.hobby = hobby;
    }

    public String getHobby() {
        return hobby;
    }

    public void setHobby(String hobby) {
        this.hobby = hobby;
    }

    @Override
    public void show() {
        System.out.println("我是一只宠物猪,我的名字叫做:" + getName() + ",性别:" + getGender() + ",爱好:" + hobby);
    }
}

class TestPet {
    public static void main(String[] args) {
        showMenu();
    }

    public static void showMenu() {
        Scanner sc = new Scanner(System.in);
        System.out.println("*************************欢迎来到宠物店*************************");
        System.out.print("请选择你要领养的宠物(1.宠物猫 2.宠物狗 3.宠物猪 4.退出):");
        int choice = sc.nextInt();
        Pet pet = null;
        switch (choice) {
            case 1:
                pet = new Cat("汤姆", "公", "波斯猫");
                pet.show();
                break;
            case 2:
                pet = new Dog("旺财", "母", 5);
                pet.show();
                break;
            case 3:
                pet = new Pig("佩奇", "公", "跳泥坑");
                pet.show();
                break;
            default:
                System.out.println("您输入的选项有误,请重新输入");
                showMenu();
                break;
        }
    }
}